package com.ze.sys.controller;

import com.ze.sys.entity.req.PageSysUserReq;
import com.ze.sys.excel.SysUserExcelExport;
import com.ze.sys.excel.SysUserExcelExport2;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@Api(tags = "用户数据导出controller")
@RestController
@RequestMapping(value = "sysUserExport")
@Slf4j
public class SysUserExportController {

    @Resource
    private SysUserExcelExport sysUserExcelExport;

    @Resource
    private SysUserExcelExport2 sysUserExcelExport2;


    @ApiOperation(value = "导出excel", notes = "导出excel")
    @GetMapping("exportData")
    public void exportData() {
        long start = System.currentTimeMillis();
        //指定数据条件
        Map<String, Object> map = new HashMap<>();
        sysUserExcelExport.exportWithBigData("用户列表", map);
        log.info("exportData cost : {}", System.currentTimeMillis() - start);
    }

    @ApiOperation(value = "导出excel", notes = "导出excel")
    @GetMapping("exportData2")
    public void exportData2() {
        long start = System.currentTimeMillis();
        sysUserExcelExport2.exportExcel("用户列表", new PageSysUserReq());
        log.info("exportData2 cost : {}", System.currentTimeMillis() - start);
    }

}
